function success(result,statusText, xhr, $form){
	if(result.status==1){
		if(result.data.status==1){
			result.data.href += '/s_r/1';
			linkTab(result.data.href,result.data.title,1);	// 保存至列表
		}else{
			$('#loader').css("display","none");
			$("#tips").html(result.info).fadeIn().delay(1000).fadeOut(400);
			loadTab();
		}
	}else if(result.status==2){
		validity(result.info,$dom);
	}else{
		$("<div>"+result.info+"</div>").dialog({
			modal: true,
			resizable: false,
			show: "Clip",
			buttons: {
				Ok: function() {
					$(this).remove();
				}
			}
		});
	}
	clearTimeout(removeLoadTime);
	var removeLoadTime = setTimeout($.removeLoading,150);
}

function searchSuccess(){
	$("#s_success").html(lang['common']['search_success']).fadeIn(400).delay(100).slideUp(400);
	$.removeLoading();
}

function validity(result,obj,appendto,topoft,leftoft){
	if(appendto){
		var show_obj = obj.find(appendto);
	}else{
		var show_obj = obj.find(".add_box");
	}
	if(obj.find("#form_error_msg").length<=0) $("<div id='form_error_msg'></div>").appendTo(show_obj);
	obj.find("#form_error_msg").html('').show();
	execValidity(result,obj,show_obj,topoft,leftoft);
	obj.find("#form_error_msg").delay(3000).fadeOut();
}

function createFormErrorMsg(element,appendto){
	element.find("#form_error_msg").html('');
	if(appendto){
		var show_obj = element.find(appendto);
	}else{
		var show_obj = element.find(".add_box");
	}
	if(element.find("#form_error_msg").length<=0) $("<div id='form_error_msg'></div>").appendTo(show_obj);
	element.find("#form_error_msg").show();
}

function execValidity(result,obj,show_obj,topoft,leftoft){
	if(!topoft) topoft = 20;
	if(!leftoft) leftoft = 0;
	$(result).each(function(){
		var info = this;
		obj.find("input[name],select[name]").each(function(){
			if($(this).attr("name")!=info.name || info.name=="") return true;
			if($(this).attr("type")=="hidden" || $(this).css("display")=="none"){
				var element = $(this).next();
			}else{
				var element = $(this);
			}
			if(element.length==0) return true;
            var box_oft = show_obj.offset();
			var oft = element.offset();
            var top_delta = parseInt(oft.top - box_oft.top);   
			var left = parseInt(oft.left)-leftoft;
			var top = top_delta - topoft; 
			$("<div></div>").addClass("validity-tooltip")
			.html(info.value).css({ "top":top+"px","left":left+"px"})
			.bind("click",function(){$(this).remove()})
			.append($('<div class="validity-tooltip-outer"></div>'))
			.appendTo(obj.find("#form_error_msg"));
		})
	})
}

function showMessage(msg,id){
	$("#"+id).html(msg).fadeIn().delay(3000).fadeOut(400);
}

function checkEpass(url){
	var bool = true;
	try{
		var ePass_rights;
		ePass_rights = new ActiveXObject("FT_ND_SC.ePsM8SC.1");
		ePass_rights.OpenDevice(1,"");
		ePass_rights.OpenFile(0,3);
		var fileLen 	= ePass_rights.GetFileInfo(0,3,3,0);
		var epass_data = ePass_rights.Read(0,0,0,fileLen);
		var epass_sn = ePass_rights.GetStrProperty(7,0,0);
		if(url){
			$.ajax({
				type: "POST",
				url: url,
				dataType: "json",
				data:"epass_no="+epass_sn+"&epass_data="+epass_data,
				cache: false,
				async: false,
				success: function(result){
					if(result.status==0){
						$("<div>"+result.info+"</div>").dialog({
							modal: true,
							resizable: false,
							buttons: {
								Ok: function() {
									$( this ).remove();
								}
							}
						});
						bool = false;
					}
				}
			});
		}
	}catch(error){
		$("<div>未检查到UsbKey信息，请确认UsbKey已正确连接！</div>").dialog({
			modal: true,
			resizable: false,
			buttons: {
				Ok: function() {
					$( this ).remove();
				}
			}
		});
		bool = false;
	}
	return bool;
}
//跳转到某一个页码
function goPage(){ 
	var v	=	$dom.find("#page_no").val(); 
	if(v>0){ 
		$dom.find("#nextPage").val(v);
		$dom.find("#ac_search").trigger("click")//就是执行#a的click事件
 
	}
	
}
//上下页面
function nextPage(v){ 
	if(v>0){
		$dom.find("#nextPage").val(v);
		$dom.find("#ac_search").trigger("click")//就是执行#a的click事件 
	}
}
// 定义一个空函数，统计的表单验证时使用。
function empty(){
	
}